package untiring07.swing.jdbc;

public class J26_SungJukService {
	private static J26_SungJukDAO sjdao;

	public boolean createSungJuk(J26_SungJukVO sj){
		sjdao = new J26_SungJukDAO();
		return sjdao.insertSungJuk(sj);
	}
	//총점,평균,학점 계산
	public void computeSungJuk(J26_SungJukVO sj){
		int tot = Integer.parseInt(sj.getKor())+
				Integer.parseInt(sj.getEng())+
				Integer.parseInt(sj.getMat());
		float avg = (float)tot/3;
		switch((int)avg/10){
		case 10 : case 9 : sj.setGrd("수");break;
		case 8  : sj.setGrd("우");break;
		case 7  : sj.setGrd("미");break;
		case 6  : sj.setGrd("양");break;
		default : sj.setGrd("가");break;
		}
		sj.setTot(tot + "");
		sj.setAvg(avg + "");
	}
	
	
}
